{template "header.html"}

<div class="note note-danger">

    <div class="row table-search-tool">
        <form action="{SELF}" method="get">
            {dr_form_search_hidden()}
            {if $mdir}
            <div class="col-md-12" style="padding-right: 0">
                <label>
                    <select name="time" class="form-control">
                        {loop $mdir $t}
                        {php $tt=str_replace('.txt', '', $t);}
                        <option {if $time==$tt} selected{/if} value="{$tt}">{if $tt=='sql'}最新{else}{dr_date($tt, 'Y-m-d H:i:s')}{/if}</option>
                        {/loop}
                    </select>
                </label>
            </div>
            {/if}

            <div class="col-md-12">
                {if $mdir}
                <label><button type="submit" class="btn blue btn-sm onloading" name="submit" > <i class="fa fa-search"></i> {dr_lang('查看')}</button></label>
                <label><button type="button" onclick="dr_ajax_option('{dr_url('sql_log/del', ['time'=>$time])}', '{dr_lang('你确定要清空全部吗？')}', 1)" class="btn red btn-sm"> <i class="fa fa-trash"></i> {dr_lang('清空')}</button></label>
                {/if}
                {if !$used}
                <label><button type="button" onclick="dr_ajax_option('{dr_url('sql_log/add')}', '{dr_lang('长时间开启会影响访问速度，你确定要开启慢查询日志吗？')}', 1)" class="btn green btn-sm"> <i class="fa fa-plus"></i> {dr_lang('开启日志功能')}</button></label>
                {else}
                <label><button type="button" onclick="dr_ajax_option('{dr_url('sql_log/add')}', '{dr_lang('你确定要关闭慢查询日志吗？')}', 1)" class="btn red btn-sm"> <i class="fa fa-close"></i> {dr_lang('关闭日志功能')}</button></label>
                {/if}
            </div>
        </form>
    </div>
</div>
<div class="right-card-box">
    <form class="form-horizontal" role="form" id="myform">
        {dr_form_hidden()}
        <div class="table-scrollable">
            <table class="table table-striped table-bordered table-hover  dataTable">
                <thead>
                <tr class="heading">
                    <th width="170">{dr_lang('时间')}</th>
                    <th width="80" style="text-align: center">{dr_lang('耗时')}</th>
                    <th>{dr_lang('标签')}</th>
                </tr>
                </thead>
                <tbody>
                {loop $list $id $t}
                <tr class="odd gradeX" id="dr_row_{$id}">
                    <td>{dr_date($t[0])}</td>
                    <td style="text-align: center">{round($t[2],2)}s</td>
                    <td>
                        {if $t.message}
                        {$t.message}
                        {else}
                        <a href="javascript:my_show({$id});">{str_replace('{list action=', '{', $t[4])}</a>
                        <div id="my_show_{$id}" style="display: none">
                            <div class="myp" style="padding: 0 20px">
                                <p>{dr_lang('耗时')}：{round($t[2],2)}s</p>
                                <p>{dr_lang('标签')}：{str_replace('{list action=', '{', $t[4])}</p>
                                <p>{dr_lang('语句')}：{$t[1]}</p>
                                <p>{dr_lang('模板')}：{$t[3]}</p>
                                <p>{dr_lang('地址')}：<a href="{$t[5]}" target="_blank">{$t[5]}</a></p>
                            </div>
                        </div>
                        {/if}
                    </td>
                </tr>
                {/loop}
                </tbody>
            </table>
        </div>
        <div class="row">
            <div class="col-md-12 col-sm-12 text-right">
                {$mypages}
            </div>
        </div>

    </form>
</div>
<script>
    function my_show(id) {
        layer.open({
            type: 1,
            title: '{dr_lang("查看")}',
            scrollbar: false,
            resize: true,
            maxmin: true, //开启最大化最小化按钮
            shade: 0,
            area: ['80%', '80%'],
            content: $('#my_show_'+id)
        });
    }
</script>
<style>
    .myp p {
        WORD-BREAK: break-all; WORD-WRAP: break-word;
        white-space: initial !important;
    }
</style>
{template "footer.html"}